﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpritePlayer : MonoBehaviour
{
    public Sprite[] sprites;//清零的集合
    public float speed=0.016f;//清零的播放速度
    public float time;
    int curlndex;
    // Update is called once per frame
    void Update()
    {
        if (sprites!=null)
        {
            if (speed>0)
            {
                time += Time.deltaTime;
                int i = (int)(time / speed);
                if (i!=curlndex)
                {
                    if (i<sprites.Length)
                    {
                        curlndex = i;
                        SpriteRenderer sr = GetComponent<SpriteRenderer>();
                        if (sr!=null)
                        {
                            sr.sprite = sprites[curlndex];
                        }
                        else
                        {
                            Destroy(gameObject);
                        }
                    }
                }
            }
        }

    }
}
